﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ArtsShop.BusinessLogic;
using System.Data;

namespace ArtsShop
{
    public partial class MyShoppingCart : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ShoppingCart sc = new ShoppingCart();
            string cartId = sc.GetShoppingCartId();
            //get customer's products
            List<BasketProduct> products = sc.getProducts(cartId);
            BindData(products);

            //calculate total
            decimal cartTotal = 1;
            //cartTotal=sc.getTotal(cartId);
            if (cartTotal > 0)
            {
                totalPrice.Text = String.Format("{o:c}", cartTotal);
            }
            else
            {
                totalPrice.Text = "";
                ShoppingCartTitle.InnerText = "Shopping Cart is Empty";
                
            }
        }

        private void BindData(DataSet products)
        {
            gridbasket.DataSource = products;
            gridbasket.DataBind();
        }

        protected void ViewDeliveryCharges_Click(object sender, EventArgs e)
        {
            Response.Redirect("DeliveryInformation.aspx");
        }
    }
}
